package com.xiaomi.controller;

import com.xiaomi.constant.MessageConstant;
import com.xiaomi.dto.AlertDTO;
import com.xiaomi.result.Result;
import com.xiaomi.service.AlertService;
import com.xiaomi.vo.AlertVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/alert")
public class AlertController {
    @Autowired
    private AlertService alertService;

    /**
     * 获取报警信息
     * @param alertDTOs
     * @return
     */
    @PostMapping
    public Result<List<AlertVO>> getAlert(@RequestBody List<AlertDTO> alertDTOs){
        log.info("上传车辆信号，确定报警信息：{}", alertDTOs);
        List<AlertVO> alertVOs = alertService.getAlert(alertDTOs);
        return Result.success(MessageConstant.GET_ALERT_SUCCESS, alertVOs);
    }

}
